package com.food.foodapi.config;

import com.food.foodapi.filter.JwtFilter;
import com.food.foodapi.utils.RedisUtil;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<JwtFilter> jwtAuthenticationFilter(RedisUtil redisService) {
        FilterRegistrationBean<JwtFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new JwtFilter(redisService));
        // 配置需要认证的路径
        registrationBean.addUrlPatterns("/*");
        return registrationBean;
    }
}

